package com.wyg.ep_mail.config;

import com.wyg.epkafkastarter.constant.Topic;
import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;

import java.util.List;

/**
 * @Author: WangYongGan
 * @Date: 2022/5/17 12:47
 * @Description: 消费者版本1，不用，用版本2 {@link KafkaListenerStarter}
 * @see KafkaListenerStarter
 */
//@Component
@Slf4j
public class KafkaConsumer {
    public static final String groupId = "ep_mail_g1";
    public static final String topic = Topic.EpMail.value;

    @KafkaListener(id = "consumer1", topics = "ep_mail", groupId = groupId)
    public void onMessage3(List<ConsumerRecord<?, ?>> records) {
        log.info(">>>批量消费一次，records.size()=" + records.size());
        for (ConsumerRecord<?, ?> record : records) {
            System.out.println(record.value());
        }
    }
}
